export const notes = $(function () {
  const note = $('#note')
  let ts = new Date(2023, 0, 1)
  let newYear = true
  if (new Date() > ts) {
    ts = new Date().getTime() + 10 * 24 * 60 * 60 * 1000
    newYear = false
  }
  $('#countdown').countdown({
    timestamp: ts,
    callback: function (days, hours, minutes, seconds) {
      let message = ''
      message += days + 'day' + (days === 1 ? '' : 's') + ','
      message += hours + 'hours' + (hours === 1 ? '' : 's') + ','
      message += minutes + 'minutes' + (minutes === 1 ? '' : 's') + 'and'
      message += seconds + 'seconds' + (seconds === 1 ? '' : 's') + '</br>'
      if (newYear) {
        message += 'left untill the new year !'
      } else {
        message += 'left to 10 days from now !'
      }
      note.html(message)
    }
  })
})
